home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 135 < prev    next >
Text File  |  1996-08-06  |  1KB  |  73 lines

  1. Path: unsw.edu.au!gwong
  2. From: gwong@cse.unsw.edu.au (Geoffrey  Wong)
  3. Newsgroups: comp.std.c
  4. Subject: y
  5. Date: 17 Jan 1996 06:48:08 GMT
  6. Organization: University of New South Wales
  7. Message-ID: <4di638$8tl@mirv.unsw.edu.au>
  8. NNTP-Posting-Host: thesis.circus.cse.unsw.edu.au
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. thanks for your help with the last problem.
  12.  
  13. However I have the follow relate problem. This time I have a structure that
  14. constains a head and a body.
  15.  
  16. struct _rlgg_rec
  17.  
  18. {
  19.  
  20.     SLiteral    head;
  21.  
  22.     SLiteral    *body;
  23.  
  24.     int         size;
  25.  
  26. };
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. Now goal is an _rlgg_rec type.
  34.  
  35. when I do:-
  36.  
  37.  goal.head = Alloc(1, SLiteral);
  38.  
  39.  
  40.  
  41. my gcc compiler complains that 
  42.  
  43.  
  44. >
  45. rlgg.c:421: warning: assignment from incompatible pointer type
  46.  
  47.  How do I allocate space for goal.head?
  48.  
  49.  
  50.  also how do I allocate space for goal.body,
  51.  
  52.  Since SLiteral is also a complex structure. I tried :-
  53. > goal.body = (SLiteral *)malloc(sizeof(SLiteral)*(TotalLiteral+1)); 
  54.  
  55.  This seemed okay, but do I need to allocate space for each goal.body[N] ???
  56.  
  57.  If I do need to then do I just use:-
  58. > goal.body[N] = (SLiteral *)malloc(sizeof(SLiteral));
  59.  
  60. This also reterns a warning:-
  61.  
  62. >rlgg.c:409: warning: assignment from incompatible pointer type
  63.  
  64. shall I be concern or just ignore the warnings?
  65.  
  66. Thanks millions 
  67.  
  68. geoff
  69. .
  70.  
  71.  
  72.  
  73.